<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<%
String path = request.getContextPath();
String date =request.getParameter("selectdate");
%>


<html>
  <head>
     
     <link rel="stylesheet" href="<%=path %>/css/flora.all.css" type="text/css" />
    <script src="<%=path %>/jquery/jquery-1[1].2.3.js" type="text/javascript"></script>
     <script src="<%=path %>/jquery/ui.datepicker.js" type="text/javascript"></script>
     
   </head>
    <script type="text/javascript">
    
   $(document).ready(function() {
	      var date="<%=date%>";
	    //如果为空则为当前日期，否则为所选日期
   if(date!="null"&&date!=""){
	 var dates= date.split("-");
	     
	 //$('#example6').datepicker.setDefaults($.datepicker.regional['ch']);
  //$('#example6').datepicker({defaultDate: new Date(2007, 2 -1, 26)});
	
	$('#example6').datepicker({onSelect: function(date) { 
             
              alert('You selected ' + date);
              var form =document.forms(0);
              form.action="<%=path%>/refresh.do?selectdate="+date;
              form.submit();
 },eventDate : "asdfsd" ,dateFormat:'yy-mm-dd',defaultDate: new Date(dates[0],dates[1]*1-1,dates[2])
});	
	
	//添加约会
	$("#input1").click( function(){
	  //  location.href="<%=path %>/addCalendar.do";
	    var form =document.forms(0);
	    form.submit();
	}
	
	);
	}else{
	
	//$.datepicker.setDefaults($.datepicker.regional['ch']);
  //$('#example6').datepicker({defaultDate: new Date(2007, 2 -1, 26)});
	
	$('#example6').datepicker({onSelect: function(date) { 
             
              alert('You selected ' + date);
              var form =document.forms(0);
              form.action="<%=path%>/refresh.do?selectdate="+date;
              form.submit();
 },eventDate : "asdfsd" ,dateFormat:'yy-mm-dd',beforeShowDay: eventDay,
   onChangeMonthYear: function(date) { 
	    alert(date);
	  }
});	
   
    function  eventDay(date){
	   return [true, 'datepicker_event'];
	   }	

	//添加约会
	$("#input1").click( function(){
	   // location.href="<%=path %>/addCalendar.do";
	      var form =document.forms(0);
	    form.submit();
	 
	}
	
	);
	
	}
});
  </script>
  <body>
  
	
<html:form  method="post" action="/addCalendar">
 
	<input id="input1" type="button" value="添加约会" >
	<div id="example6"  align="left" ></div>
	<div style="clear: both;" align="left"></div>
	

   <table align="right">
     <tr>
      <td>
       时间
      </td>
      <td>
      我的日历 
      </td>
     </tr>
     <c:forEach var="calendar" items="${calendarList}">
      <tr>
      ${calendar.event} 
      </tr>
     </c:forEach>
     <c:forEach var="i" begin ="4" end="17">
      <tr>
       <td>
       ${i}：00
       </td> 
      </tr> 
     
     </c:forEach>
      
   
   </table>   
  
 </html:form>

  </body>
</html>
